<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>FileCreateShortcut</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>FileCreateShortcut</h1>

<p>Creates a shortcut (.lnk) file.</p>

<pre class="Syntax">FileCreateShortcut, Target, LinkFile [, WorkingDir, Args, Description, IconFile, ShortcutKey, IconNumber, RunState]</pre>
<h3>Parameters</h3>
<dl>

  <dt>Target</dt>
  <dd><p>Name of the file that the shortcut refers to, which should include an absolute path unless the file is integrated with the system (e.g. Notepad.exe). The file does not have to exist at the time the shortcut is created; in other words, shortcuts to invalid targets can be created.</p></dd>

  <dt>LinkFile</dt>
  <dd><p>Name of the shortcut file to be created, which is assumed to be in <a href="../Variables.htm#WorkingDir">%A_WorkingDir%</a> if an absolute path isn't specified. Be sure to include the <strong>.lnk</strong> extension. If the file already exists, it will be overwritten.</p></dd>

  <dt>WorkingDir</dt>
  <dd><p>Directory that will become <em>Target's</em> current working directory when the shortcut is launched. If blank or omitted, the shortcut will have a blank &quot;Start in&quot; field and the system will provide a default working directory when the shortcut  is launched.</p></dd>

  <dt>Args</dt>
  <dd><p>Parameters that will be passed to <em>Target</em> when it is launched. Separate parameters with spaces. If a parameter contains spaces, enclose it in double quotes.</p></dd>

  <dt>Description</dt>
  <dd><p>Comments that describe the shortcut (used by the OS to display a tooltip, etc.)</p></dd>

  <dt>IconFile</dt>
  <dd><p>The full path and name of the icon to be displayed for <em>LinkFile</em>.  It must either be an ico file or the very first icon of an EXE or DLL.</p></dd>

  <dt>ShortcutKey</dt>
  <dd><p>A single letter, number, or the name of a single key from the <a href="../KeyList.htm">key list</a> (mouse buttons and other non-standard keys might not be supported). <strong>Do not</strong> include modifier symbols. Currently, all shortcut keys are created as CTRL+ALT shortcuts. For example, if the letter B is specified for this parameter, the shortcut key will be CTRL-ALT-B.</p></dd>

  <dt>IconNumber</dt>
  <dd><p>To use an icon in <em>IconFile</em> other than the first, specify that number here (can be an <a href="../Variables.htm#Expressions">expression</a>). For example, 2 is the second icon.</p></dd>

  <dt>RunState</dt>
  <dd><p>To have <em>Target</em> launched minimized or maximized, specify one of the following digits:</p>
      <p>1 - Normal (this is the default)<br>
3 - Maximized<br>
7 - Minimized</p></dd>

</dl>
<h3>ErrorLevel</h3>
<p><span class="ver">[v1.1.04+]</span> This command is able to throw an exception on failure. For more information, see <a href="Catch.htm#RuntimeErrors">Runtime Errors</a>.</p>
<p><a href="../misc/ErrorLevel.htm">ErrorLevel</a> is set to 1 if there was a problem or 0 otherwise.</p>
<h3>Remarks</h3>
<p><em>Target</em> might not need to include a path if the target file resides in one of the folders listed in the system's PATH environment variable.</p>
<p>The <em>ShortcutKey</em> of a newly created shortcut will have no effect unless the shortcut file resides on the desktop or somewhere in the Start Menu. If the <em>ShortcutKey</em> you choose is already in use, your new shortcut takes precedence.</p>
<p>An alternative way to create a shortcut to a URL is the following example, which creates a special URL shortcut. Change the first two parameters to suit your preferences:<br>
<code><a href="IniWrite.htm">IniWrite</a>, http://www.google.com, C:\My Shortcut.url, InternetShortcut, URL</code>.</p>
<p>The following may be optionally added to assign an icon to the above:</p>
<pre><a href="IniWrite.htm">IniWrite</a>, &lt;IconFile&gt;, C:\My Shortcut.url, InternetShortcut, IconFile
<a href="IniWrite.htm">IniWrite</a>, 0, C:\My Shortcut.url, InternetShortcut, IconIndex</pre>
<p>In the above, replace 0 with the index of the icon (0 is used for the first icon) and replace &lt;IconFile&gt; with a URL, EXE, DLL, or ICO file. Examples: C:\Icons.dll, C:\App.exe, http://www.somedomain.com/ShortcutIcon.ico</p>
<p>The operating system will treat a .URL file created by the above as a real shortcut even though it is a plain text file rather than a .LNK file.</p>
<h3>Related</h3>
<p><a href="FileGetShortcut.htm">FileGetShortcut</a>, <a href="FileAppend.htm">FileAppend</a></p>
<h3>Example</h3>
<pre class="NoIndent"><em>; The letter &quot;i&quot; in the last parameter makes the shortcut key be Ctrl-Alt-I:</em>
FileCreateShortcut, Notepad.exe, %A_Desktop%\My Shortcut.lnk, C:\, &quot;%A_ScriptFullPath%&quot;, My Description, C:\My Icon.ico, i</pre>

</body>
</html>
